#!/usr/bin/env python3
"""
测试脚本：向 Neo4j 插入节点
"""

import asyncio
import json
import sys

try:
    from mcp import ClientSession, StdioServerParameters  # type: ignore
    from mcp.client.stdio import stdio_client  # type: ignore
except ImportError:
    print("Error: mcp not found. Please install the MCP SDK.")
    sys.exit(1)

async def create_node():
    """创建节点的测试函数"""
    server_params = StdioServerParameters(
        command="uv",
        args=["run", "python", "main.py"],
        env=None
    )
    
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            # 初始化会话
            await session.initialize()
            
            print("正在创建节点...")
            
            # 调用 create_node 工具
            result = await session.call_tool(
                "create_node",
                {
                    "label": "yanxx",
                    "properties": {
                        "k": 1,
                        "a": 2,
                        "c": 3
                    }
                }
            )
            
            print("\n=== 创建节点结果 ===")
            for content in result.content:
                if hasattr(content, 'text'):
                    print(content.text)
                else:
                    print(content)
            
            return result

if __name__ == "__main__":
    asyncio.run(create_node())